package com.example.jump.controller;

import com.example.jump.pojo.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("user")
public class UserController {

    @RequestMapping("1")
    public Map<String, Object> userTest() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", "1");
        map.put("username", "macro");
        map.put("password", "123456");
        return map;
    }

    @RequestMapping("2")
    public Map<String, Object> userTest2() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", "1");
        map.put("username", "mph");
        map.put("password", "123456");
        return map;
    }

    @RequestMapping(value = "getByUsername", method = RequestMethod.GET)
    public Map<String, Object> getByUsername(@RequestParam(value = "username") String username) {
        Map<String, Object> map = new HashMap<>();
        if (username != null && username.equals("macro")) {
            map.put("姓名", "macro");
            map.put("密码", "123456");
            return map;
        }
        map.put("last", "最后");
        return map;
    }
}
